package ctrl;

import java.util.Collection;

import com.beimin.eveapi.account.characters.CharactersParser;
import com.beimin.eveapi.account.characters.CharactersResponse;
import com.beimin.eveapi.account.characters.EveCharacter;
import com.beimin.eveapi.character.assetlist.AssetListParser;
import com.beimin.eveapi.core.ApiAuthorization;
import com.beimin.eveapi.eve.typename.EveTypeName;
import com.beimin.eveapi.eve.typename.TypeNameParser;
import com.beimin.eveapi.eve.typename.TypeNameResponse;
import com.beimin.eveapi.exception.ApiException;
import com.beimin.eveapi.shared.assetlist.AssetListResponse;
import com.beimin.eveapi.shared.assetlist.EveAsset;

public class EVEAPICtrl {
  public EVEAPICtrl() {

    // CharactersParser parser = CharactersParser.getInstance();
    // AssetListParser assetParser = AssetListParser.getInstance();
    // TypeNameParser typeParser = TypeNameParser.getInstance();
    // XMLReader myReader = XMLReaderFactory.createXMLReader();
    
    // int keyId = 2277170;
    // String vCode =
    // "PQ17xbCBTxoqkRc7aCQ5IFUdI5NVHrTpsVs2ujNiny60lF1rdeGjruF8lTVQ88YE";
    // ApiAuthorization auth = new ApiAuthorization(keyId, vCode);
    // CharactersResponse response = parser.getResponse(auth);
    // AssetListResponse assetResponse = assetParser.getResponse(auth);
    // Collection<EveCharacter> eveCharacters = response.getAll();
    // for (EveCharacter eveCharacter : eveCharacters) {
    // System.out.println(eveCharacter.getName());
    // }

    // Set<EveAsset<EveAsset<?>>> assets = assetResponse.getAll();
    // for (EveAsset eveAsset : assets) {
    //
    // }

    // String url = "http://api.eve-central.com/api/marketstat?typeid="
    // + eveAsset.getTypeID();
    // System.out.println(url);
    // myReader.setContentHandler(xmlHandler);
    // myReader.parse(new InputSource(new URL(url).openStream()));
    //
    // _dump(xmlHandler._getValueMap(), "buy");

    try {
      TypeNameParser typeParser = TypeNameParser.getInstance();
      TypeNameResponse typeResponse = typeParser.getResponse(1351);
      Collection<EveTypeName> chars = typeResponse.getAll();
      for (EveTypeName eveTypeName : chars) {

        System.out.println(eveTypeName.getTypeName());
      }
    }
    catch (ApiException e) {
      e.printStackTrace();
    }
  }
}
